<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Admin\Member;
use Illuminate\Support\Facades\Input;
class MemberController extends Controller
{
    //会员列表
    public function index(){
    	//获取数据
    	$data = Member::get();
    	//显示视图
    	return view('admin.member.index',['data' => $data]);
    }

    //会员增加
    public function add(){
    	if(Input::method() == 'POST'){
    		//接收数据
    		$data = Input::all();
    		//写入数据
    		$result = Member::insert([
    				'username'	=>	$data['username'],
    				'password'	=>	bcrypt('123456'),
    				'gender'	=>	$data['gender'],
    				'mobile'	=>	$data['mobile'],
    				'email'		=>	$data['email'],
    				'avatar'	=>	$data['avatar'],
    				'created_at'=>	date('Y-m-d H:i:s'),
    				'type'		=>	$data['type'],
    				'status'	=>	$data['status']
    			]);
    		//返回结果
    		return $result ? '1' : '0';
    	}else{
    		//显示视图文件
    		return view('admin.member.add');
    	}
    }
}
